#import <Foundation/Foundation.h>

extern int hpricot_scan(char *port);

int main(int argc, const char *argv[])
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  const char *s = "<html><body>abc</body></html>";
  if (argc < 2) {
    NSLog(@"Need input file name. Use an example for now.");
  } else {
    NSString *path = [NSString stringWithUTF8String: argv[1]];
#ifdef GNUSTEP
    NSString *str = [NSString stringWithContentsOfFile: path];
#else
    NSString *str = [NSString stringWithContentsOfFile: path
                            encoding: NSUTF8StringEncoding
                            error: NULL];
#endif
    if (str) {
      s = [str UTF8String];
    } else {
      NSLog(@"No contents from file %@. Use an example for now.", path);
    }
  }
  hpricot_scan((char*)s);
  [pool release];
  return 0;
}
